<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath()%>/css/base.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.pager.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/admin.js"></script>
<title>Insert title here</title>
</head>
<BODY class=list style="min-width:500px"><DIV class=bar>商品列表&nbsp;总记录数: ${page.totalRowsAmount} (共${page.totalPages}页) </DIV>
<DIV class=body>
<FORM id=listForm name=goodslist method=post action=goodsselect.do>
<DIV class=listBar>
 &nbsp;&nbsp; <LABEL>查找: </LABEL>
 <INPUT type=text name=searchKey value=${param.searchKey}> 
  &nbsp;&nbsp; <LABEL>类别: </LABEL>
 <INPUT type=text name=type value=${param.type}> 
 <INPUT hideFocus id=searchButton class=formButton value="搜 索" type=button > &nbsp;&nbsp; 
 <LABEL>每页显示: </LABEL>
 <SELECT id=pageSize name=page.pageSize> 
 <OPTION value=10 ${page.pageSize==10?'selected':''}>10</OPTION> 
 <OPTION value=20 ${page.pageSize==20?'selected':''}>20</OPTION> 
 <OPTION value=50 ${page.pageSize==50?'selected':''}>50</OPTION> 
 <OPTION value=100 ${page.pageSize==100?'selected':''}>100</OPTION>
 </SELECT> 
 </DIV>
<TABLE id=listTable class=listTable>
<TBODY>
<TR>
<TH class=check><INPUT class=allCheck type=checkbox > </TH>
<TH><A hideFocus class=sort href="#" name=goodsName >商品名称</A> </TH>
<TH><A hideFocus class=sort href="#" name=goodType>分类</A> </TH>
<TH><A hideFocus class=sort href="#" name=price >销售价</SPAN> </A></TH>
<TH><A hideFocus class=sort href="#" name=isMarketable >上架</A> </TH>
<TH><A hideFocus class=sort href="#" name=isBest>精品</A> </TH>
<TH><A hideFocus class=sort href="#" name=isNew>新品</A> </TH>
<TH><A hideFocus class=sort href="#" name=isHot>热销</A> </TH>
<TH><A class=sort href="#" name=sort>排序</A> </TH>
<TH><A class=sort href="#" name=goodsNum>库存</A> </TH>
</TR>
<c:forEach items="${goodslist}" var="goods">
<TD><INPUT value=${goods.id} type=checkbox name=ids> </TD>
<TD><SPAN title=${goods.goodsName}>${goods.goodsName}</SPAN></TD>
<TD>${goods.goodType.typeName} </TD>
<TD>￥${goods.price}元 </TD>
<TD><SPAN class=${goods.isMarketable==1?'trueIcon':'falseIcon'}>&nbsp;</SPAN> </TD>
<TD><SPAN class=${goods.isBest==1?'trueIcon':'falseIcon'}>&nbsp;</SPAN> </TD>
<TD><SPAN class=${goods.isNew==1?'trueIcon':'falseIcon'}>&nbsp;</SPAN> </TD>
<TD><SPAN class=${goods.isHot==1?'trueIcon':'falseIcon'}>&nbsp;</SPAN> </TD>
<TD>${goods.sort}</TD>
<TD>${goods.goodsNum}</TD>
</TR>
</c:forEach>
</TBODY>
</TABLE>
<DIV class=pagerBar>
<DIV class=delete><INPUT id=save class=formButton  value="确认" type=button onclick="saveSelectGoods()" > </DIV>
<DIV class=pager>
<SPAN id=pager>

</SPAN>

<INPUT id=pageNumber type=hidden name=page.pageNumber value=${page.currentPage} > 
<INPUT id=totalSize type=hidden name=page.totalSize value=${page.totalRowsAmount} > 
<INPUT id=orderBy type=hidden name=pager.orderBy value=${page.orderBy} > 
<INPUT id=order  type=hidden name=pager.order value=${page.order}> 
</DIV>
</DIV>
</FORM>
</DIV>
</BODY>

<SCRIPT type=text/javascript>
$().ready( function() {
	
	var $pager = $("#pager");
	
	$pager.pager({
		pagenumber: ${page.currentPage},
		pagecount: ${page.totalPages},
		buttonClickCallback: $.gotoPage
	});

})

function goodsedit(id)
{
  document.goodslist.action="goodsedit.do?id="+id;
  document.goodslist.submit(); 
}

function saveSelectGoods()
{
  var ids=document.getElementsByName("ids");
  var value='';   
  for (var i=0;i<ids.length;i++ ){ 
   if(ids[i].checked){ //判断复选框是否选中    
     if(value.length>0)
     {
     value=value+','+ids[i].value;
     }else
     {
     value=ids[i].value;
     }
   }   
   }
 if(value.length==0)
   {
     alert("请至少选择一个商品!")
   }
 else
 {  
   window.parent.closeGoods(value);
  }
  
}
</SCRIPT>
</html>